@echo off
set bin=%1
set axf=%2
set keilpath=%3
set app_addr=%4
echo current file:%bin%.bin
echo current axf:%axf%
echo current keilpath:%keilpath%
echo app_addr :%app_addr%'

:: out bin
%keilpath%\ARM\ARMCC\bin\fromelf.exe --bin --output=.\out\bin\%bin%.bin %axf%
:: out DFU
..\..\..\..\tool\xBin2Dfu\xBin2Dfu.exe -s .\out\bin\%bin%.bin -o .\out\bin\ -n 4
:: merge bin(boot+app)
..\..\..\..\tool\xMerge\merge_file.exe -s ..\CX32L003_BOOT_UART\out\bin\cx32_boot_uart.bin -t .\out\bin\%bin%.bin -p %app_addr% -o .\out\bin\boot_%bin%.bin

:: 生成JLINK脚本
echo erase > download.jlink
echo loadfile .\out\bin\boot_%bin%.bin 0x0 >> download.jlink
echo r >> download.jlink
echo qc >> download.jlink
